package com.ruoyi.laiwu.controller;

import cn.dev33.satoken.annotation.SaIgnore;
import cn.hutool.http.HttpRequest;
import cn.hutool.http.HttpResponse;
import cn.hutool.http.HttpUtil;
import cn.hutool.json.JSONArray;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.ruoyi.common.core.domain.R;


import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.redis.RedisUtils;
import com.ruoyi.laiwu.domain.LwStationBase;
import com.ruoyi.laiwu.domain.UmEventLwq;
import com.ruoyi.laiwu.mapper.*;
import com.ruoyi.laiwu.util.AkskSampleApplication;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.PostConstruct;
import java.io.*;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.nio.charset.StandardCharsets;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors;


@RestController
@RequestMapping("service")
@SaIgnore
@Slf4j
@RequiredArgsConstructor
public class ApiController {

    private JSONObject jsonObject;

    @PostConstruct
    public void init() throws IOException {
//        File file = new File("C:\\Users\\Administrator\\Desktop\\data.json");
        File file = new File("C:\\Users\\Lenovo\\Desktop\\laiwu\\data.json");
        jsonObject= JSONUtil.readJSONObject(file, StandardCharsets.UTF_8);
//        queryShuiWei();
    }

    private final LwSysPatrolRiverRecordMapper lwSysPatrolRiverRecordMapper;

    private final LwRiverLeaderMapper lwRiverLeaderMapper;

    private final LwStationBaseMapper lwStationBaseMapper;

    /**
     * 应急防汛：
     * 各月平均风速表返回值：
     */
    @GetMapping("{type}")
    public R winds(@PathVariable("type") String type,String table,String url,String pageNum,String pageSize){
        if(type.equals("queryByTable")){
            return R.ok(queryByTable(table));
        }
        if("skxx".equals(type)){
            return R.ok(skxx());
        }
        if("api".equals(type)){
            if(StringUtils.isBlank(url)){
                return R.fail("url can not be blank");
            }
            url = "http://10.173.126.3:30007"+"/x-gateway-service/api-market/6/"+url;

            if(StringUtils.isBlank(pageNum)){
                pageNum="1";
            }
            if(StringUtils.isBlank(pageSize)){
                pageSize="100";
            }
            if(Integer.valueOf(pageSize)>200){
                return R.fail("pageSize can not > 200");
            }
            String token = null;
            try {
                token = AkskSampleApplication.getToken();
                System.out.println(token);
            } catch (IOException e) {
                System.out.println(url+"?pageNum="+pageNum+"&pageSize="+pageSize);
            }
            HttpRequest get = HttpUtil.createGet(url);
            HashMap<String, String> header = new HashMap<>();
            header.put("x-token",token);
            get.addHeaders(header);
            HashMap<String, Object> form = new HashMap<>();
            form.put("pageSize",pageSize);
            form.put("pageNumber",pageNum);
            form.put("returnTotalSize",1);
            get.form(form);
            HttpResponse execute = get.execute();
            JSONObject entries = JSONUtil.parseObj(execute.body());
           return  R.ok(entries);
        }
        if("cmaweather".equals(type)){
            HttpRequest get = HttpUtil.createGet("https://weather.cma.cn/api/weather/view?stationid=54828");
            HttpResponse execute = get.execute();
            return R.ok(JSONUtil.parseObj(execute.body()).getObj("data"));
        }
        if("nljcyj".equals(type)){
            return R.ok(nljcyj());
        }
      if("GetAQIDataPublishLive".equals(type)){
            HttpRequest get = HttpUtil.createGet("https://air.cnemc.cn:18007/CityData/GetAQIDataPublishLive?cityName=济南市");
            HttpResponse execute = get.execute();
          JSONArray objects = JSONUtil.parseArray(execute.body());
          JSONArray objects1 = new JSONArray();
          for (Object o : objects) {
              JSONObject entries = JSONUtil.parseObj(o);
              String positionName = entries.getStr("PositionName");
              if("莱芜战役纪念馆".equals(positionName)||"泰兴公司".equals(positionName)||"技术学院".equals(positionName)){
                  BigDecimal pm25 = entries.getBigDecimal("PM2_5",BigDecimal.ZERO);
                  BigDecimal pm2524h = entries.getBigDecimal("PM2_5_24h",BigDecimal.ZERO);
                  BigDecimal pm10 = entries.getBigDecimal("PM10",BigDecimal.ZERO);
                  BigDecimal pm1024h = entries.getBigDecimal("PM10_24h",BigDecimal.ZERO);
                  BigDecimal aqi = entries.getBigDecimal("AQI",BigDecimal.ZERO);
                  BigDecimal sum = pm25.add(pm10).add(aqi);
                  BigDecimal sum_24h = pm2524h.add(pm1024h).add(aqi);
                  BigDecimal avg = sum.divide(new BigDecimal(3),2, RoundingMode.HALF_UP);
                  BigDecimal avg_24h = sum_24h.divide(new BigDecimal(3),2, RoundingMode.HALF_UP);
                  entries.putOpt("AVG",avg);
                  entries.putOpt("AVG_24h",avg_24h);
                  objects1.add(entries);
              }
          }

          return R.ok(objects1);
        }
        if("jxhzl_sjzsqsfx_r".equals(type)){
            //事件列表
            return R.ok(jxhzl_sjzsqsfx_r());
        }
        if("sk_num".equals(type)){
            //事件列表
            return R.ok(sk_num());
        }
       if("jxhzl_sjzsqsfx_n".equals(type)){
            //事件列表
            return R.ok(jxhzl_sjzsqsfx_n());
        }
        if("jxhzl_sjlb".equals(type)){
            //事件列表
            return R.ok(jxhzl_sjlb());
        }
       if(type.startsWith("ajgl_zlzytj")){
            //案件概览：治理资源统计  日
           QueryWrapper<UmEventLwq> wrapper = new QueryWrapper<>();
           wrapper.orderByDesc("report_time");
           wrapper.last("limit 1");
           UmEventLwq umEventLwq = umEventLwqMapper.selectOne(wrapper);
           Date reportTime = umEventLwq.getReportTime();
           LocalDate parse = LocalDate.parse(DateUtils.dateTime(reportTime));
           String str = parse.toString();
           if("ajgl_zlzytj_r".equals(type)){
               str = parse.toString();
           }
           if("ajgl_zlzytj_y".equals(type)){
                str = parse.format(DateTimeFormatter.ofPattern("yyyy-MM"));
           }
           if("ajgl_zlzytj_n".equals(type)){
               str = ""+parse.getYear();
           }
           return R.ok(ajgl_zlzytj(str));
       }
        if("jxhzl_yqrc".equals(type)){
            //舆情热词
            return R.ok(jxhzl_yqrc());
        }
        if("ajgl_sjfb_jdb".equals(type)){
            //时间分布  街道办
            return R.ok(ajgl_sjfb_jdb());
        }
        if("jxhzl_sjgf".equals(type)){
            //事件高发
            return R.ok(jxhzl_sjgf());
        }
        if("ajgl_sjfb_qxbm".equals(type)){
            //事件分布  曲线部门
            return R.ok(ajgl_sjfb_qxbm());
        }
        if("yld_fb".equals(type)){
            //易涝点分布
            return R.ok(yld_fb());
        }
        if("xhrw".equals(type)){
            //巡河任务统计
            return R.ok(xhrw());
        }
        if("jcry".equals(type)){
            //河长级别统计
            return R.ok(jcry());
        }
        if("yljc".equals(type)){
            //河长级别统计
            return R.ok(yljc());
        }
        if("cxxswsk".equals(type)){
            return R.ok(cxxswsk());
        }
        if("RQ_jwd".equals(type)){
            return R.ok(sk_jwd("RQ"));
        }
        if("pp_jwd".equals(type)){
            return R.ok(sk_jwd("PP"));
        }
        if("ZZ_jwd".equals(type)){
            return R.ok(sk_jwd("ZZ"));
        }
        if("ZQ_jwd".equals(type)){
            return R.ok(sk_jwd("ZQ"));
        }
        if("RR_jwd".equals(type)){
            return R.ok(sk_jwd("RR"));
        }
        if("widns".equals(type)){
            return R.ok(widns());
        }
        if("avg_temp".equals(type)){
            return R.ok(avg_temp());
        }
        if("avg_rain".equals(type)){
            return R.ok(avg_rain());
        }
         if("yljc1".equals(type)){
            return R.ok(yljc1());
        }
         if("swz".equals(type)){
             return R.ok(swz());
         }
       if("jyl_tj".equals(type)){
             return R.ok(jyl_tj());
         }
        return R.ok(jsonObject.get(type));
    }

    public Object jyl_tj() {

        String  sql = "select * from (select stnm,stlc,lw_st_pptn_r_v.* from lw_station_base join lw_st_pptn_r_v on lw_station_base.stcd = lw_st_pptn_r_v.stcd ) a where a.stcd is not null order by daily_total desc";
        List<Map<String,Object>> result = lwStationBaseMapper.queryjyl_tj();
        return result;
    }


    private Object swz() {
        JSONArray list_sk = AkskSampleApplication.getPageData("/x-gateway-service/api-market/6/oqv3q57t45gknjn5cplzv55u4u", 1, 1000);
        JSONArray list_m = AkskSampleApplication.getPageData("/x-gateway-service/api-market/6/cedzscbndrakbiqmqyzepwww7i", 1, 1000);
        JSONArray list_st = JSONUtil.parseArray(queryByTable("ns_datamidjinanlaiwu_laiwu_37.dwd_st_stbprp_b"));
        JSONArray list_fhbz = AkskSampleApplication.getPageData("/x-gateway-service/api-market/6/7xbzjwrmlvghhjlakqgeqtsmni", 1, 1000);//防洪指标
//        String sql_m = "select * from ns_datamidjinanlaiwu_laiwu_37.stg_st_rsvr_stbprp_rela";
//        String sql_sk = "select * from ns_datamidjinanlaiwu_laiwu_37.stg_digital_river_reservoir_b";
//        String sql_st = "select * from ns_datamidjinanlaiwu_laiwu_37.dwd_st_stbprp_b";
//        List list_m = AkskSampleApplication.queryData(sql_m);
//        List list_sk = AkskSampleApplication.queryData(sql_sk);
//        List list_st = AkskSampleApplication.queryData(sql_st);
        JSONArray result = new JSONArray();
        for (Object o : list_m) {
            JSONObject m = JSONUtil.parseObj(o);
            String rscd = m.getStr("rscd");
            String stcd = m.getStr("stcd");
            for (Object object : list_sk) {
                JSONObject sk = JSONUtil.parseObj(object);
                if(sk.getStr("rs_code").equals(rscd)){
                    m.putOpt("sk_info",sk);
                    break;
                }
            }
            for (Object object : list_st) {
                JSONObject st = JSONUtil.parseObj(object);
                if(st.getStr("stcd").equals(stcd)){
                    m.putOpt("st_info",st);
                    break;
                }
            }
            for (Object object : list_fhbz) {
                JSONObject st = JSONUtil.parseObj(object);
                if(st.getStr("stcd").equals(stcd)){
                    m.putOpt("fhzb_info",st);
                    break;
                }
            }
            JSONObject stInfo = m.getJSONObject("st_info");
            if(stInfo!=null&&stInfo.getStr("sttp").equalsIgnoreCase("RQ")){
                result.add(m);
            }
        }
        return result;
    }


    private Object skxx() {
        JSONArray list_sk = AkskSampleApplication.getPageData("/x-gateway-service/api-market/6/oqv3q57t45gknjn5cplzv55u4u", 1, 1000);
        JSONArray list_m = AkskSampleApplication.getPageData("/x-gateway-service/api-market/6/cedzscbndrakbiqmqyzepwww7i", 1, 1000);
//        JSONArray list_st = AkskSampleApplication.getPageData("/x-gateway-service/api-market/6/wscv5sj3uzfadl2hunt2qbykfe", 1, 1000);
        JSONArray list_st =JSONUtil.parseArray(queryByTable("ns_datamidjinanlaiwu_laiwu_37.dwd_st_stbprp_b"));
        JSONArray list_fhbz = AkskSampleApplication.getPageData("/x-gateway-service/api-market/6/7xbzjwrmlvghhjlakqgeqtsmni", 1, 1000);//防洪指标
//        String sql_m = "select * from ns_datamidjinanlaiwu_laiwu_37.stg_st_rsvr_stbprp_rela";
//        String sql_sk = "select * from ns_datamidjinanlaiwu_laiwu_37.stg_digital_river_reservoir_b";
//        String sql_st = "select * from ns_datamidjinanlaiwu_laiwu_37.dwd_st_stbprp_b";
//        List list_m = AkskSampleApplication.queryData(sql_m);
//        List list_sk = AkskSampleApplication.queryData(sql_sk);
//        List list_st = AkskSampleApplication.queryData(sql_st);
        JSONArray result = new JSONArray();
        for (Object o : list_m) {
            JSONObject m = JSONUtil.parseObj(o);
            String rscd = m.getStr("rscd");
            String stcd = m.getStr("stcd");
            for (Object object : list_sk) {
                JSONObject sk = JSONUtil.parseObj(object);
                if(sk.getStr("rs_code").equals(rscd)){
                    m.putOpt("sk_info",sk);
                    break;
                }
            }
            for (Object object : list_st) {
                JSONObject st = JSONUtil.parseObj(object);
                if(st.getStr("stcd").equals(stcd)){
                    m.putOpt("st_info",st);
                    break;
                }
            }
            for (Object object : list_fhbz) {
                JSONObject st = JSONUtil.parseObj(object);
                if(st.getStr("stcd").equals(stcd)){
                    m.putOpt("fhzb_info",st);
                    break;
                }
            }
            result.add(m);
        }
        return result;
    }

    private List queryByTable(String table){
        String sql = "select * from "+table;
        return AkskSampleApplication.queryData(sql);
    }


    private Object avg_rain() {
        String sql = "select * from ns_datamidjinanlaiwu_laiwu_37.dwd_sjtb_yl_yjfxlwqypjjsl98378";
        List list = AkskSampleApplication.queryData(sql);
        JSONArray result = new JSONArray();
        JSONObject entries = JSONUtil.parseObj(list.get(0));
        for (Map.Entry<String, Object> entry : entries) {
            JSONObject entries1 = new JSONObject();
            entries1.putOpt("value",entry.getValue());
            boolean exist = false;
            switch (entry.getKey()){
                case "c_january":
                    exist = true;
                    entries1.putOpt("name","1月");
                    break;
                case "c_february":
                    exist = true;
                    entries1.putOpt("name","2月");
                    break;
                case "c_march":
                    exist = true;
                    entries1.putOpt("name","3月");
                    break;
                case "c_april":
                    exist = true;
                    entries1.putOpt("name","4月");
                    break;
                case "c_may":
                    exist = true;
                    entries1.putOpt("name","5月");
                    break;
                case "c_june":
                    exist = true;
                    entries1.putOpt("name","6月");
                    break;
                case "c_july":
                    exist = true;
                    entries1.putOpt("name","7月");
                    break;
                case "c_august":
                    exist = true;
                    entries1.putOpt("name","8月");
                    break;
                case "c_september":
                    exist = true;
                    entries1.putOpt("name","9月");
                    break;
                case "c_october":
                    exist = true;
                    entries1.putOpt("name","10月");
                    break;
                case "c_november":
                    exist = true;
                    entries1.putOpt("name","11月");
                    break;
                case "c_december":
                    exist = true;
                    entries1.putOpt("name","12月");
                    break;
            }
            if(exist){
                result.add(entries1);
            }
        }
        return result;
    }

    private Object avg_temp() {
        String sql = "select * from ns_datamidjinanlaiwu_laiwu_37.dwd_sjtb_yl_yjfxypjqw89095";
        List list = AkskSampleApplication.queryData(sql);
        JSONArray result = new JSONArray();
        JSONObject entries = JSONUtil.parseObj(list.get(0));
        for (Map.Entry<String, Object> entry : entries) {
            JSONObject entries1 = new JSONObject();
            entries1.putOpt("value",entry.getValue());
            boolean exist = false;
            switch (entry.getKey()){
                case "c_january":
                    exist = true;
                    entries1.putOpt("name","1月");
                    break;
                case "c_february":
                    exist = true;
                    entries1.putOpt("name","2月");
                    break;
                case "c_march":
                    exist = true;
                    entries1.putOpt("name","3月");
                    break;
                case "c_april":
                    exist = true;
                    entries1.putOpt("name","4月");
                    break;
                case "c_may":
                    exist = true;
                    entries1.putOpt("name","5月");
                    break;
                case "c_june":
                    exist = true;
                    entries1.putOpt("name","6月");
                    break;
                case "c_july":
                    exist = true;
                    entries1.putOpt("name","7月");
                    break;
                case "c_august":
                    exist = true;
                    entries1.putOpt("name","8月");
                    break;
                case "c_september":
                    exist = true;
                    entries1.putOpt("name","9月");
                    break;
                case "c_october":
                    exist = true;
                    entries1.putOpt("name","10月");
                    break;
                case "c_november":
                    exist = true;
                    entries1.putOpt("name","11月");
                    break;
                case "c_december":
                    exist = true;
                    entries1.putOpt("name","12月");
                    break;
            }
            if(exist){
                result.add(entries1);
            }
        }
        return result;
    }

    private Object widns() {
        String sql = "select * from ns_datamidjinanlaiwu_laiwu_37.dwd_sjtb_yl_yjfxpjfsb132399";
        List list = AkskSampleApplication.queryData(sql);
        JSONArray result = new JSONArray();
        JSONObject entries = JSONUtil.parseObj(list.get(0));
        for (Map.Entry<String, Object> entry : entries) {
            JSONObject entries1 = new JSONObject();
            entries1.putOpt("value",entry.getValue());
            boolean exist = false;
            switch (entry.getKey()){
                case "c_january":
                    exist = true;
                    entries1.putOpt("name","1月");
                    break;
                case "c_february":
                    exist = true;
                    entries1.putOpt("name","2月");
                    break;
                case "c_march":
                    exist = true;
                    entries1.putOpt("name","3月");
                    break;
                case "c_april":
                    exist = true;
                    entries1.putOpt("name","4月");
                    break;
                case "c_may":
                    exist = true;
                    entries1.putOpt("name","5月");
                    break;
                case "c_june":
                    exist = true;
                    entries1.putOpt("name","6月");
                    break;
                case "c_july":
                    exist = true;
                    entries1.putOpt("name","7月");
                    break;
                case "c_august":
                    exist = true;
                    entries1.putOpt("name","8月");
                    break;
                case "c_september":
                    exist = true;
                    entries1.putOpt("name","9月");
                    break;
                case "c_october":
                    exist = true;
                    entries1.putOpt("name","10月");
                    break;
                case "c_november":
                    exist = true;
                    entries1.putOpt("name","11月");
                    break;
                case "c_december":
                    exist = true;
                    entries1.putOpt("name","12月");
                    break;
            }
            if(exist){
                result.add(entries1);
            }
        }
        return result;
    }

    private Object cxxswsk() {
        QueryWrapper<LwStationBase> wrapper = new QueryWrapper<>();
        wrapper.eq("sttp","RQ");
        List<Map<String, Object>> maps = lwStationBaseMapper.selectMaps(wrapper);
        for (Map<String, Object> map : maps) {
//             order by tm desc limit 1
            JSONObject entries = queryByStcd(map.get("stcd").toString());
            if(entries==null){
                continue;
            }
            map.put("tm",entries.getStr("tm"));
            map.put("z",entries.getStr("z"));
        }

        AtomicInteger count = new AtomicInteger(1);
        maps = maps.stream().map(i -> {
            HashMap<String, Object> stringObjectHashMap = new HashMap<>();
            if (count.get() < 10) {
                stringObjectHashMap.put("number", "0" + count.get());
            } else {
                stringObjectHashMap.put("number", count.get());
            }
            stringObjectHashMap.put("waterlogging", i.get("stnm"));
            stringObjectHashMap.put("monitorTime", i.get("tm"));
            stringObjectHashMap.put("waterName", i.get("rvnm"));
            stringObjectHashMap.put("waterLevel", i.get("z") + "m");
            stringObjectHashMap.put("lon", i.get("lgtd"));
            stringObjectHashMap.put("lat", i.get("lttd"));
            count.getAndIncrement();
            return stringObjectHashMap;
        }).collect(Collectors.toList());
        return maps;
    }

    private Object sk_jwd(String sttp) {
        QueryWrapper<LwStationBase> wrapper = new QueryWrapper<>();
        wrapper.eq("sttp",sttp);
        List<Map<String, Object>> maps = lwStationBaseMapper.selectMaps(wrapper);
        maps = maps.stream().map(i->{
            HashMap<String, Object> map = new HashMap<>();
            map.put("stationName",i.get("stnm"));//测站名称
            map.put("station",i.get("stcd"));//测站编码
            map.put("riverName",i.get("rvnm"));//河流名称
            map.put("waterName",i.get("hnnm"));//水系名称
            map.put("street",i.get("stlc"));//站址
            map.put("lon",i.get("lgtd"));//经度
            map.put("lat",i.get("lttd"));//纬度
            map.put("basinName",i.get("bsnm"));//流域名称
            return map;
        }).collect(Collectors.toList());
        return maps;
    }

    public JSONObject queryByStcd(String stcd){
        if(RedisUtils.isExistsObject("river_r_"+stcd)){
            return RedisUtils.getCacheObject("river_r_"+stcd);
        }
        return null;
    }



    public void getByStcd(String stcd){
        String sql = "select stcd,tm,z from ns_datamidjinanlaiwu_laiwu_37.dwd_st_river_r where stcd = '"+stcd+"' order by tm desc limit 1 ";
        List list = AkskSampleApplication.queryData(sql);
        if(list.size()>0){
            JSONObject entries = JSONUtil.parseObj(list.get(0));
            RedisUtils.setCacheObject("river_r_"+stcd,entries);
        }
    }


    @Scheduled(cron = "0 23 23 * * ? ")
    public void queryShuiWei(){
        JSONArray list_st = JSONUtil.parseArray(queryByTable("ns_datamidjinanlaiwu_laiwu_37.dwd_st_stbprp_b"));
        for (Object map : list_st) {
            JSONObject entries = JSONUtil.parseObj(map);
            System.out.println("开始加载"+entries.getStr("stcd"));
            getByStcd(entries.getStr("stcd"));
            System.out.println("结束加载"+entries.getStr("stcd"));
        }
    }



    private Object nljcyj() {
        QueryWrapper<LwStationBase> wrapper = new QueryWrapper<>();
        wrapper.eq("sttp","RR");
        List<Map<String, Object>> maps = lwStationBaseMapper.selectMaps(wrapper);
        for (Map<String, Object> map : maps) {
//             order by tm desc limit 1
            JSONObject entries = queryByStcd(map.get("stcd").toString());
            if(entries==null){
                continue;
            }
            map.put("tm",entries.getStr("tm"));
            map.put("z",entries.getStr("z"));
        }

        AtomicInteger count = new AtomicInteger(1);
        maps = maps.stream().map(i -> {
            HashMap<String, Object> stringObjectHashMap = new HashMap<>();
            if (count.get() < 10) {
                stringObjectHashMap.put("number", "0" + count.get());
            } else {
                stringObjectHashMap.put("number", count.get());
            }
            stringObjectHashMap.put("waterlogging", i.get("stnm"));
            stringObjectHashMap.put("monitorTime", i.get("tm"));
            stringObjectHashMap.put("waterName", i.get("rvnm"));
            stringObjectHashMap.put("waterLevel", i.get("z") + "m");
            stringObjectHashMap.put("lon", i.get("lgtd"));
            stringObjectHashMap.put("lat", i.get("lttd"));
            count.getAndIncrement();
            return stringObjectHashMap;
        }).collect(Collectors.toList());
        return maps;
    }


    private final LwReservoirInfoMapper lwReservoirInfoMapper;

    private Object sk_num() {
        JSONArray list_sk = AkskSampleApplication.getPageData("/x-gateway-service/api-market/6/oqv3q57t45gknjn5cplzv55u4u", 1, 1000);
        JSONArray list_m = AkskSampleApplication.getPageData("/x-gateway-service/api-market/6/cedzscbndrakbiqmqyzepwww7i", 1, 1000);
        JSONArray list_st = JSONUtil.parseArray(queryByTable("ns_datamidjinanlaiwu_laiwu_37.dwd_st_stbprp_b"));
        ArrayList<Map<String, Object>> result = new ArrayList<>();
        int swz = 0;
        for (Object o : list_m) {
            JSONObject m = JSONUtil.parseObj(o);
            String stcd = m.getStr("stcd");
            for (Object object : list_st) {
                JSONObject st = JSONUtil.parseObj(object);
                if(st.getStr("stcd").equals(stcd)){
                    if(st.getStr("sttp").equals("RQ")){
                        swz++;
                    }
                    break;
                }
            }
        }
        HashMap<String, Object> map = new HashMap<>();
        map.put("name","水库数量");
        map.put("value",list_sk.size());
        map.put("unit","个");
        result.add(map);
        HashMap<String, Object> map1 = new HashMap<>();
        map1.put("name","水位站数量");
        map1.put("value",swz);
        map1.put("unit","个");
        result.add(map1);
        return result;
    }

    private Object jxhzl_sjzsqsfx_n() {
        List<Map<String, Object>> maps = umEventLwqMapper.jxhzl_sjzsqsfx_n();
        return maps;
    }

    private Object jxhzl_sjzsqsfx_r() {
        List<Map<String, Object>> maps = umEventLwqMapper.jxhzl_sjzsqsfx_r();
        return maps;
    }


    private Object ajgl_zlzytj(String str) {
        String sql = "select case_status name,count(1) value from um_event_lwq where case_status != -1 and report_time GROUP BY case_status order by value desc";
        QueryWrapper<UmEventLwq> wrapper = new QueryWrapper<>();
        wrapper.select("case_status name","count(1) value");
        wrapper.ne("case_status",-1);
        wrapper.likeRight("report_time",str);
        wrapper.groupBy("case_status");
        wrapper.orderByDesc("value");
        List<Map<String, Object>> maps = umEventLwqMapper.selectMaps(wrapper);
        return ajgl_zlzytj1(maps);
    }



    private Object ajgl_zlzytj1(List<Map<String, Object>> maps) {
        int all = 0;
        int ing = 0;
        int end = 0;
        for (Map<String, Object> map : maps) {
            int status = Integer.parseInt(map.get("name").toString());
            int num = Integer.parseInt(map.get("value").toString());
            if(status==-1){
                continue;
            }
            all+=num;
            if(status==0||status==2){
                ing+=num;
                continue;
            }
            if(status==1){
                end+=num;
            }
        }
        ArrayList<Map<String, Object>> result = new ArrayList<>();
        HashMap<String, Object> allm = new HashMap<>();
        allm.put("name","案件总数");
        allm.put("value",all);
        allm.put("unit","件");
        allm.put("img","img/center1.df09cdd0.png");
        result.add(allm);




        HashMap<String, Object> allm2 = new HashMap<>();
        allm2.put("name","处置中");
        allm2.put("value",ing);
        allm2.put("unit","件");
        allm2.put("img","img/center2.8fed9aa1.png");
        result.add(allm2);


        HashMap<String, Object> allm3 = new HashMap<>();
        allm3.put("name","已结案");
        allm3.put("value",end);
        allm3.put("unit","件");
        allm3.put("img","img/center3.eda888f8.png");
        result.add(allm3);



        HashMap<String, Object> allm1 = new HashMap<>();
        allm1.put("name","结案率");
        allm1.put("value",100);
        if(all!=0){
            BigDecimal divide = new BigDecimal(end).multiply(new BigDecimal(100)).divide(new BigDecimal(all), 2, BigDecimal.ROUND_HALF_UP);
            allm1.put("value",divide);
            if(end==all){
                allm1.put("value",100);;
            }
        }
        allm1.put("unit","%");
        allm1.put("img","img/center4.b3322c95.png");
        result.add(allm1);

        return result;
    }

    private Object ajgl_sjfb_qxbm() {
        List<Map<String, Object>> maps = umEventLwqMapper.ajgl_sjfb_qxbm();
        return maps;
    }

    private Object ajgl_sjfb_jdb() {
        List<Map<String, Object>> maps = umEventLwqMapper.ajgl_sjfb_jdb();
        return maps;
    }

    private Object jxhzl_sjgf() {
        List<Map<String, Object>> maps = umEventLwqMapper.queryByGroup("case_class_name");
        AtomicInteger count  = new AtomicInteger(0);
        maps = maps.stream().map(i ->{
            HashMap<String, Object> hashMap = new HashMap<>();
            hashMap.put("ind", "0"+count.incrementAndGet());
            String name = i.get("name").toString();
            hashMap.put("type", name.substring(name.lastIndexOf("-")+1));
            hashMap.put("num",i.get("value"));
            hashMap.put("unit", "次");
            return hashMap;
        }).collect(Collectors.toList());
        return maps;
    }



    private Object jxhzl_sjlb() {
        List<Map<String, Object>> maps = umEventLwqMapper.queryListMap();
        return maps;
    }

    private final UmEventLwqMapper umEventLwqMapper;


    private Object jxhzl_yqrc() {
        List<Map<String, Object>> maps = umEventLwqMapper.queryByGroup("question_desc");
        return maps;
    }

    private Object yld_fb() {
//        String sql = "select stlc name,count(1) value from ns_datamidjinanlaiwu_laiwu_37.stg_st_stbprp_b where sttp == 'RR' group by stlc order value desc";
//        List list = AkskSampleApplication.queryData(sql);
        QueryWrapper<LwStationBase> wrapper = new QueryWrapper<>();
        wrapper.select("stlc name","count(1) value");
        wrapper.eq("sttp","RR");
        wrapper.groupBy("stlc");
        wrapper.orderByDesc("value");
        List<Map<String, Object>> maps = lwStationBaseMapper.selectMaps(wrapper);
        return maps;
    }

    public Object yljc(){
        String sql = "select * from ns_datamidjinanlaiwu_laiwu_37.dwd_sjtb_yl_zhnyjyljc18963";
        List list = AkskSampleApplication.queryData(sql);
        JSONObject entries = JSONUtil.parseObj(list.get(0));
        Integer num = lwStationBaseMapper.queryPPNum();
        ArrayList<Map<String, Object>> maps = new ArrayList<>();
        HashMap<String, Object> map = new HashMap<>();
        map.put("name","雨量监测站");
        map.put("value",num);
        map.put("unit","个");
        maps.add(map);
        HashMap<String, Object> map1 = new HashMap<>();
        map1.put("name","年平均累计降水量");
        map1.put("value",entries.get("c_accumulatedrainfall"));
        map1.put("unit","mm");
        maps.add(map1);
        HashMap<String, Object> map2 = new HashMap<>();
        map2.put("name","年平均降水量");
        map2.put("value",entries.get("c_averagerainfall"));
        map2.put("unit","mm");
        maps.add(map2);
        return maps;
    }


    public Object yljc1(){
        String sql = "select * from ns_datamidjinanlaiwu_laiwu_37.dwd_sjtb_yl_zhnyjyljc18963";
        List list = AkskSampleApplication.queryData(sql);
        JSONObject entries = JSONUtil.parseObj(list.get(0));
        ArrayList<Map<String, Object>> maps = new ArrayList<>();
        HashMap<String, Object> map1 = new HashMap<>();
        map1.put("name","年平均累计降水量");
        map1.put("value",entries.get("c_accumulatedrainfall"));
        map1.put("unit","mm");
        maps.add(map1);
        HashMap<String, Object> map2 = new HashMap<>();
        map2.put("name","年平均降水量");
        map2.put("value",entries.get("c_averagerainfall"));
        map2.put("unit","mm");
        maps.add(map2);
        return maps;
    }


    public Object jcry(){
        String sql = "select river_leader_level,count(1) num from ns_datamidjinanlaiwu_laiwu_37.dwd_sys_river_leader group by river_leader_level";
        List list = AkskSampleApplication.queryData(sql);

//        List<Map<String,Object>>  map = lwRiverLeaderMapper.queryLeader();
        JSONArray objects = new JSONArray();
        for (Object o : list) {
            JSONObject entries1 = JSONUtil.parseObj(o);
            JSONObject entries = new JSONObject();
            if(entries1.getStr("river_leader_level").equals("4")){
                entries.putOpt("name","镇级河长");
            }else
            if(entries1.getStr("river_leader_level").equals("5")){
                entries.putOpt("name","村级河长");
            }else {
               continue;
            }
            entries.putOpt("value",entries1.getInt("num"));
            entries.putOpt("unit","人");
            objects.add(entries);
        }
        return objects;
    }

    /**
     * 巡河任务
     * @return
     */
    public Object xhrw(){

//        String sql = "select * from ns_datamidjinanlaiwu_laiwu_37.dwd_sys_patrol_river_record";
//        List list = AkskSampleApplication.queryData(sql);

        List<Map<String,Object>> result = lwSysPatrolRiverRecordMapper.queryXhrw();
        JSONArray objects = new JSONArray();
        int allCount = 0;
        int finishCount = 0;
        for (Map<String, Object> stringObjectMap : result) {
            Integer num = Integer.valueOf(stringObjectMap.get("num").toString());
            allCount+=num;
            if(stringObjectMap.get("status").toString().equals("2")){

                finishCount+=num;
            }
        }
        JSONObject entries = new JSONObject();
        entries.putOpt("name","应巡次数");
        entries.putOpt("value",allCount);
        entries.putOpt("unit","次");
        objects.add(entries);
        JSONObject entries2 = new JSONObject();
        entries2.putOpt("name","已巡次数");
        entries2.putOpt("value",finishCount);
        entries2.putOpt("unit","次");
        objects.add(entries2);
        JSONObject entries1 = new JSONObject();
        entries1.putOpt("name","巡检率");
        entries1.putOpt("value",new BigDecimal(finishCount).multiply(BigDecimal.valueOf(100L)).divide(BigDecimal.valueOf(allCount),0,BigDecimal.ROUND_HALF_UP));
        entries1.putOpt("unit","%");
        objects.add(entries1);
        return objects;
    }


//
//
//
//    /**
//     * 各城区易涝点分布
//     * @return
//     */
//    @GetMapping("yld_fb")
//    public R yld_fb(){
//        return R.ok(jsonObject.get("yld_fb"));
//    }
//
//
//    /**
//     * 全区月平均降雨量
//     * @return
//     */
//    @GetMapping("avg_rain")
//    public R avg_rain(){
//        return R.ok(jsonObject.get("avg_rain"));
//    }
//
//    /**
//     * 月均降雨量及蒸发量
//     * @return
//     */
//    @GetMapping("rain_evaporation")
//    public R rain_evaporation(){
//        return R.ok(jsonObject.get("rain_evaporation"));
//    }
//
//    /**
//     * 水库及水位站数量
//     * @return
//     */
//    @GetMapping("sk_num")
//    public R sk_num(){
//        return R.ok(jsonObject.get("sk_num"));
//    }
//
//    /**
//     * 预警等级
//     * @return
//     */
//    @GetMapping("yjdj")
//    public R yjdj(){
//        return R.ok(jsonObject.get("yjdj"));
//    }
//
//    /**
//     * 监测人员
//     * @return
//     */
//    @GetMapping("jcry")
//    public R jcry(){
//        return R.ok(jsonObject.get("jcry"));
//    }
//
//
//    /**
//     * 雨量检测
//     * @return
//     */
//    @GetMapping("yljc")
//    public R yljc(){
//        return R.ok(jsonObject.get("yljc"));
//    }
//
//    /**
//     * 月平均气温
//     * @return
//     */
//    @GetMapping("avg_temp")
//    public R avg_temp(){
//        return R.ok(jsonObject.get("avg_temp"));
//    }
//
//
//    /**
//     * 超汛限水位水库
//     * @return
//     */
//    @GetMapping("cxxswsk")
//    public R cxxswsk(){
//        return R.ok(jsonObject.get("cxxswsk"));
//    }
//
//    /**
//     * 内涝监测预警
//     * @return
//     */
//    @GetMapping("nljcyj")
//    public R nljcyj(){
//        return R.ok(jsonObject.get("nljcyj"));
//    }
//
//
//    /**
//     * 城市管理：
//     * 数字城管平台
//     * @return
//     */
//    @GetMapping("szcgpt")
//    public R szcgpt(){
//        return R.ok(jsonObject.get("szcgpt"));
//    }
//
//
//    /**
//     * 案件概览：事件分布：
//     * 街道办
//     * @return
//     */
//    @GetMapping("ajgl_sjfb_jdb")
//    public R ajgl_sjfb_jdb(){
//        return R.ok(jsonObject.get("ajgl_sjfb_jdb"));
//    }
//
//    /**
//     * 区县部门
//     * @return
//     */
//    @GetMapping("ajgl_sjfb_qxbm")
//    public R ajgl_sjfb_qxbm(){
//        return R.ok(jsonObject.get("ajgl_sjfb_qxbm"));
//    }
//
//    /**
//     * 精细化治理：事件分布
//     * @return
//     */
//    @GetMapping("jxhzl_sjfb")
//    public R jxhzl_sjfb(){
//        return R.ok(jsonObject.get("jxhzl_sjfb"));
//    }
//
//    /**
//     * 事件高发
//     * @return
//     */
//    @GetMapping("jxhzl_sjgf")
//    public R jxhzl_sjgf(){
//        return R.ok(jsonObject.get("jxhzl_sjgf"));
//    }
//
//    /**
//     * 事件列表
//     * @return
//     */
//    @GetMapping("jxhzl_sjlb")
//    public R jxhzl_sjlb(){
//        return R.ok(jsonObject.get("jxhzl_sjlb"));
//    }
//
//    /**
//     * 事件上报来源分析
//     * @return
//     */
//    @GetMapping("jxhzl_sjsblyfx")
//    public R jxhzl_sjsblyfx(){
//        return R.ok(jsonObject.get("jxhzl_sjsblyfx"));
//    }
//
//    /**
//     * 事件总数趋势分析：
//     * 日：
//     * @return
//     */
//    @GetMapping("queryWind")
//    public R queryWind(){
//        return R.ok(jsonObject.get("winds"));
//    }
//
//
//    @GetMapping("jxhzl_sjzsqsfx_r")
//    public R jxhzl_sjzsqsfx_r(){
//        return R.ok(jsonObject.get("jxhzl_sjzsqsfx_r"));
//    }
//
//    @GetMapping("queryWind")
//    public R queryWind(){
//        return R.ok(jsonObject.get("winds"));
//    }
//    @GetMapping("queryWind")
//    public R queryWind(){
//        return R.ok(jsonObject.get("winds"));
//    }
//    @GetMapping("queryWind")
//    public R queryWind(){
//        return R.ok(jsonObject.get("winds"));
//    }
//
//    @GetMapping("queryWind")
//    public R queryWind(){
//        return R.ok(jsonObject.get("winds"));
//    }
//
//
//    @GetMapping("queryWind")
//    public R queryWind(){
//        return R.ok(jsonObject.get("winds"));
//    }
//
//    @GetMapping("queryWind")
//    public R queryWind(){
//        return R.ok(jsonObject.get("winds"));
//    }
//    @GetMapping("queryWind")
//    public R queryWind(){
//        return R.ok(jsonObject.get("winds"));
//    }
//
//
//    @GetMapping("queryWind")
//    public R queryWind(){
//        return R.ok(jsonObject.get("winds"));
//    }
//
//
//    @GetMapping("queryWind")
//    public R queryWind(){
//        return R.ok(jsonObject.get("winds"));
//    }
//
//    @GetMapping("queryWind")
//    public R queryWind(){
//        return R.ok(jsonObject.get("winds"));
//    }
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//    /**
//     * 查询村镇河长数量
//     * @return
//     */
//    @GetMapping("query_hz_num")
//    public R  query_hz_num(){
//        return R.ok(jsonObject.get(""));
//    }
//
//    /**
//     * 雨量监测站数量
//     * @return
//     */
//    @GetMapping("query_yljcz")
//    public R<Integer> query_yljcz(){
//        return R.ok(slhhStStbprpBMapper.query_yljcz());
//    }
//
//
//
//
//    @GetMapping("query_xhrw")
//    public R<List<HashMap<String, Object>>> query_xun_he_ren_wu(){
//
//        List<HashMap<String, Object>> result = new ArrayList<>();
//
//        HashMap<String, Object> map = new HashMap<>();
//        map.put("name","应巡次数");
//        map.put("value",96796);
//        map.put("unit","次");
//        result.add(map);
//        HashMap<String, Object> map1 = new HashMap<>();
//        map1.put("name","已巡次数");
//        map1.put("value",28969);
//        map1.put("unit","次");
//        result.add(map1);
//        HashMap<String, Object> map2 = new HashMap<>();
//        map2.put("name","巡检率");
//        map2.put("value","30%");
//        map2.put("unit","次");
//        result.add(map2);
//        return R.ok(result);
//    }
//
//
//    private HashSet<String> columnType = new HashSet<>();
//    @GetMapping("importData")
//    public void importData() throws IOException, ParseException {
////        insert_public("air_quality_assessment_rewards_and_punishments","air_quality_assessment_rewards_and_punishments","");
////        insert_public("air_quality_ranking_info","air_quality_ranking_info","");
//        long start = System.currentTimeMillis();
////        insert_public("slhh_st_pptn_r","stg_st_pptn_r","应急防汛数据中台导出数据\\");
////        insert_public("slhh_st_river_r","stg_st_river_r","应急防汛数据中台导出数据\\");
////        insert_public("slhh_st_rsvr_r","stg_st_rsvr_r","应急防汛数据中台导出数据\\");
////        insert_public("slhh_st_rsvrfcch_b","stg_st_rsvrfcch_b","应急防汛数据中台导出数据\\");
//        insert_public("slhh_st_stbprp_b","stg_st_stbprp_b","应急防汛数据中台导出数据\\");
//        insert_public("slhh_sys_patrol_river_record","stg_sys_patrol_river_record","应急防汛数据中台导出数据\\");
//        insert_public("slhh_sys_river_leader","stg_sys_river_leader","应急防汛数据中台导出数据\\");
//        long end = System.currentTimeMillis();
//        System.out.println(end-start);
////        insert_public("um_event_lwq","um_event_lwq","");
//    }
//
//    private final GenTableColumnMapper genTableColumnMapper;
//
//
//    private void insert_public(String tableName,String filename,String dir) throws IOException, ParseException {
//        BufferedReader bufferedReader = new BufferedReader(new FileReader("C:\\Users\\Administrator\\Desktop\\环保数据中台导出数据 (2)\\" + dir + filename + ".csv"));
//        String s = bufferedReader.readLine().replaceAll("\"", "");
//        String[] fields = s.split(StringUtils.SEPARATOR);
//        List<GenTableColumn> genTableColumns = genTableColumnMapper.selectDbTableColumnsByName(tableName);
//        String string;
//        while ((string = bufferedReader.readLine())!=null){
//             string = string.replaceAll("\"", "");
//            String[] values = string.split(StringUtils.SEPARATOR);
//            ArrayList<Map<String, String>> row = new ArrayList<>();
//            for (int i = 0; i < fields.length; i++) {
//                HashMap<String, String> map = new HashMap<>();
//                map.put("line",string);
//                map.put("field",fields[i]);
//                int finalI = i;
//                map.put("type", genTableColumns.stream().filter(a -> a.getColumnName().equals(fields[finalI])).map(GenTableColumn::getColumnType).findFirst().get());
//                if(values.length>i){
//                    map.put("value",values[i]);
//                }else{
//                    map.put("value","");
//                }
//                row.add(map);
//            }
//            StringBuilder sql = new StringBuilder("insert into "+tableName+ " (");
//            for (Map<String, String> column : row) {
//                sql.append(column.get("field")).append(",");
//            }
//            sql.deleteCharAt(sql.length()-1);
//            sql.append(") values(");
//            for (Map<String, String> column : row) {
//                if(column.get("type").startsWith("varchar")){
//                    sql.append("'").append(column.get("value")).append("',");
//                }
//                if(column.get("type").startsWith("datetime")){
//                    String s1 = column.get("value");
//                    if(StringUtils.isNotBlank(s1)){
//                        try{
//                            sql.append("'").append(getDateStr(column.get("value"))).append("',");
//                        }catch (StringIndexOutOfBoundsException e){
//                            System.out.println(row);
//                            System.out.println(column);
//                            throw new GlobalException(e.getMessage());
//                        }
//                    }else{
//                        sql.append("null,");
//                    }
//                }
//                if(column.get("type").startsWith("decimal")||column.get("type").startsWith("double")||column.get("type").startsWith("bigint")){
//                    if(StringUtils.isBlank(column.get("value"))){
//                        sql.append("null").append(",");
//                    }else{
//                        sql.append(column.get("value")).append(",");
//                    }
//                }
//            }
//            sql.deleteCharAt(sql.length()-1);
//            sql.append(");\n");
//            System.out.println(sql);
//            FileUtil.appendString(sql.toString(),"C:\\Users\\Administrator\\Desktop\\环保数据中台导出数据 (2)\\sql\\"+dir+tableName+".sql", Charset.defaultCharset());
//        }
//        bufferedReader.close();
//    }
//
//    private String getDateStr(String value) {
//        if(value.indexOf("/")>0){
//            return DateUtil.format(DateUtil.parse(value,"d/M/yyyy HH:mm:ss"),"yyyy-MM-dd HH:mm:ss");
//        }
//        return value.substring(0,value.indexOf("."));
//    }
//
//    private final SlhhStRiverRMapper slhhStRiverRMapper;
//
//    private void insert_slhh_st_river_r() throws IOException, ParseException {
//        List<String> strings = Files.readAllLines(Paths.get("C:\\Users\\Administrator\\Desktop\\环保数据中台导出数据 (2)\\应急防汛数据中台导出数据\\stg_st_river_r.csv"));
//        strings.remove(0);
//        ArrayList<SlhhStRiverR> slhhStRiverRS = new ArrayList<>();
//        for (String string : strings) {
//            String[] split = string.split(StringUtils.SEPARATOR);
//            SlhhStRiverR slhhStRiverR = new SlhhStRiverR();
//            if(split.length>0&&StrUtil.isNotBlank(split[0])){
//                slhhStRiverR.setStcd(split[0]);
//            }
//            if(split.length>1&&StrUtil.isNotBlank(split[1])){
//                SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.0");
//                slhhStRiverR.setTm(simpleDateFormat.parse(split[1]));
//            }
//            if(split.length>2&&StrUtil.isNotBlank(split[2])){
//                slhhStRiverR.setZ(Double.valueOf(split[2]));
//            }
//            if(split.length>3&&StrUtil.isNotBlank(split[3])){
//                slhhStRiverR.setQ(Double.valueOf(split[3]));
//            }
//            if(split.length>4&&StrUtil.isNotBlank(split[4])){
//                slhhStRiverR.setXsa(Double.valueOf(split[4]));
//            }
//            if(split.length>5&&StrUtil.isNotBlank(split[5])){
//                slhhStRiverR.setXsavv(Double.valueOf(split[5]));
//            }
//            if(split.length>6&&StrUtil.isNotBlank(split[6])){
//                slhhStRiverR.setXsmxv(Double.valueOf(split[6]));
//            }
//            if(split.length>7&&StrUtil.isNotBlank(split[7])){
//                slhhStRiverR.setFlwchrcd(split[7]);
//            }
//            if(split.length>8&&StrUtil.isNotBlank(split[8])){
//                slhhStRiverR.setWptn(split[8]);
//            }
//            if(split.length>9&&StrUtil.isNotBlank(split[9])){
//                slhhStRiverR.setMsqmt(split[9]);
//            }
//            if(split.length>10&&StrUtil.isNotBlank(split[10])){
//                slhhStRiverR.setMsamt(split[10]);
//            }
//            if(split.length>11&&StrUtil.isNotBlank(split[11])){
//                slhhStRiverR.setMsvmt(split[11]);
//            }
//            slhhStRiverRS.add(slhhStRiverR);
//        }
//        slhhStRiverRMapper.delete(new LambdaQueryWrapper<>());
//        slhhStRiverRMapper.insertBatch(slhhStRiverRS);
//    }
//
//
//
//
//    private void insert_slhh_st_pptn_r() throws IOException, ParseException {
//        List<String> strings = Files.readAllLines(Paths.get("C:\\Users\\Administrator\\Desktop\\环保数据中台导出数据 (2)\\应急防汛数据中台导出数据\\stg_st_pptn_r.csv"));
//        strings.remove(0);
//        ArrayList<SlhhStPptnR> slhhStPptnRS = new ArrayList<>();
//        for (String string : strings) {
//            String[] split = string.split(StringUtils.SEPARATOR);
//            SlhhStPptnR slhhStPptnR = new SlhhStPptnR();
//            if(split.length>0&&StrUtil.isNotBlank(split[0])){
//                slhhStPptnR.setStcd(split[0]);
//            }
//            if(split.length>1&&StrUtil.isNotBlank(split[1])){
//                SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.0");
//                slhhStPptnR.setTm(simpleDateFormat.parse(split[1]));
//            }
//            if(split.length>2&&StrUtil.isNotBlank(split[2])){
//                slhhStPptnR.setDrp(Double.valueOf(split[2]));
//            }
//            if(split.length>3&&StrUtil.isNotBlank(split[3])){
//                slhhStPptnR.setIntv(Double.valueOf(split[3]));
//            }
//            if(split.length>4&&StrUtil.isNotBlank(split[4])){
//                slhhStPptnR.setPdr(Double.valueOf(split[4]));
//            }
//            if(split.length>5&&StrUtil.isNotBlank(split[5])){
//                slhhStPptnR.setDyp(Double.valueOf(split[5]));
//            }
//            if(split.length>6&&StrUtil.isNotBlank(split[6])){
//                slhhStPptnR.setWth(split[6]);
//            }
//            slhhStPptnRS.add(slhhStPptnR);
//        }
//        slhhStPptnRMapper.delete(new LambdaQueryWrapper<>());
//        slhhStPptnRMapper.insertBatch(slhhStPptnRS);
//    }
//
//
//
//    private void insert_slhh_st_rsvr_r() throws IOException, ParseException {
//        List<String> strings = Files.readAllLines(Paths.get("C:\\Users\\Administrator\\Desktop\\环保数据中台导出数据 (2)\\应急防汛数据中台导出数据\\stg_st_rsvr_r.csv"));
//        strings.remove(0);
//        ArrayList<SlhhStRsvrR> slhhStRsvrRBos = new ArrayList<>();
//        for (String string : strings) {
//            String[] split = string.split(StringUtils.SEPARATOR);
//            SlhhStRsvrR slhhStRsvrRBo = new SlhhStRsvrR();
//            slhhStRsvrRBo.setStcd(split[0]);
//            if(split.length>1&&StrUtil.isNotBlank(split[1])){
//                SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.0");
//                slhhStRsvrRBo.setTm(simpleDateFormat.parse(split[1]));
//            }
//            if(split.length>2&&StrUtil.isNotBlank(split[2])){
//                slhhStRsvrRBo.setRz(Double.valueOf(split[2]));
//            }
//            if(split.length>3&&StrUtil.isNotBlank(split[3])){
//                slhhStRsvrRBo.setInq(Double.valueOf(split[3]));
//            }
//            if(split.length>4&&StrUtil.isNotBlank(split[4])){
//                slhhStRsvrRBo.setW(Double.valueOf(split[4]));
//            }
//            if(split.length>5&&StrUtil.isNotBlank(split[5])){
//                slhhStRsvrRBo.setOtq(Double.valueOf(split[5]));
//            }
//            if(split.length>6&&StrUtil.isNotBlank(split[6])){
//                slhhStRsvrRBo.setRwchrcd(split[6]);
//            }
//            if(split.length>7&&StrUtil.isNotBlank(split[7])){
//                slhhStRsvrRBo.setRwptn(split[7]);
//            }
//            if(split.length>7&&StrUtil.isNotBlank(split[8])){
//                slhhStRsvrRBo.setInqdr(Double.valueOf(split[8]));
//            }
//            if(split.length>8&&StrUtil.isNotBlank(split[9])){
//                slhhStRsvrRBo.setMsqmt(split[9]);
//            }
//            slhhStRsvrRBos.add(slhhStRsvrRBo);
//            System.out.println(string);
//        }
//        slhhStRsvrRMapper.delete(new LambdaQueryWrapper<>());
//        slhhStRsvrRMapper.insertBatch(slhhStRsvrRBos);
//    }
}
